home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / Sessions / Completions / Completions Source / Execution Queues / ApplicationWaker.h < prev    next >
Encoding:
Text File  |  1998-06-17  |  1.3 KB  |  57 lines  |  [TEXT/CWIE]

  1. // ApplicationWaker.h
  2.  
  3. #ifndef ApplicationWaker_h
  4. #define ApplicationWaker_h
  5.  
  6. #ifndef A5_h
  7. #include "A5.h"
  8. #endif
  9. #ifndef __TIMER__
  10. #include <Timer.h>
  11. #endif
  12. #ifndef __PROCESSES__
  13. #include <Processes.h>
  14. #endif
  15.  
  16. /*
  17.     This class is a way out of a timing problem:  When an interrupt task
  18.     wants a rendezvous with the application, it has to make sure the
  19.     application wakes up.  But WakeUpProcess alone won't do the job;
  20.     the application might be on its way to bed, but not asleep enough for
  21.     WakeUpProcess to do anything.  The solution is to keep calling
  22.     WakeUpProcess until the application wakes up.
  23. */
  24.  
  25. class ApplicationWaker
  26.   {
  27.     private:
  28.         ProcessSerialNumber process;
  29.         volatile bool awake;
  30.         volatile bool ringing;
  31.         volatile bool canSleep;
  32.         TMTask timeTask;
  33.         A5 a5;
  34.         
  35.         static pascal void RingAlarmGlue();
  36.         static pascal void RingAlarm( ApplicationWaker * );
  37.         
  38.         ApplicationWaker();
  39.         
  40.     public:
  41.         // Make sure the first call, which initializes the object,
  42.         // is from application time.
  43.             static ApplicationWaker& The();
  44.         
  45.         // Call this from interrupt time to wake the application.
  46.             void StartAlarm();
  47.         
  48.         // Call this from application time when the application wakes up.
  49.             void StopAlarm();
  50.         
  51.         // Call this before going to sleep.  If it returns false, use a sleep
  52.         // time of zero.
  53.             bool CanSleep();
  54.   };
  55.  
  56. #endif
  57.